<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ include file="navbar.jsp" %>
	
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'file.jsp' starting page</title>
	<link rel="stylesheet" type="text/css" href="styles/css/bootstrap.min.css" />
  </head>
  
  <body class="body">
  	<div class="container" style="margin-top:60px;width:960px;margin-left:auto;margin-right:auto;">

	  <div class="row">
		
		
		<!-- 导入左侧部分 -->
		<jsp:include page="side.jsp">
			<jsp:param value="file" name="tag"/>
		</jsp:include>
		
		
		<div class="span9">
			
			<ul class="breadcrumb" style="margin-bottom:0px;border-radius: 3px 3px 0 0;margin-top:15px">
				<li class="active">

					<a href="file.jspx"><i class="icon-th"></i>文件列表</a>
				</li>
				<li class="pull-right"><i class="icon-plus"></i><a href="file.jspx?m=add&p=${param.p }" class="link-black">创建文件夹</a></li>
			</ul>
			<div class="wall" style="border:1px solid #ddd;padding:15px">
				<table class="table table-striped">
					<thead>
						<tr>
							<th width="30px"></th>
							<th width="20%">名称</th>
							<th width="20%">文件个数</th>
							<th width="20%">大小</th>
							<th>创建人</th>
							<th width="10%"></th>
						</tr>
					</thead>
					<tbody>
						<c:choose>
							<c:when test="${requestScope.folderpage == null }">
								您还未上传任何文件，请点此上传！
							</c:when>
						<c:otherwise>
						
						<c:forEach items="${requestScope.folderpage.result }" var="fd">
						<tr>
							<td>
								<img src="styles/img/folder.png"/>
							</td>
							<td><a href="file.jspx?m=file&id=${fd.folderId }&p=${param.p }">${fd.folderName }</a></td>
							<td>${fd.fileNum}</td>
							<td>
								<c:choose>
									<c:when test="${fd.folderSize < 1024 }">
									<fmt:formatNumber  type="number" value="${fd.folderSize }"></fmt:formatNumber>B
									</c:when>
									<c:when test="${fd.folderSize >= 1024 &&fd.folderSize < 1048576 }">
										<fmt:formatNumber  type="number" value="${fd.folderSize/1024 }" pattern="#0.0"></fmt:formatNumber>K	
									</c:when>
									<c:when test="${fd.folderSize >= 1048576 &&fd.folderSize < 1073741824 }">
										<fmt:formatNumber  type="number" value="${fd.folderSize/1048576 }" pattern="#0.0"></fmt:formatNumber>M
									</c:when>
									<c:when test="${fd.folderSize >= 1073741824 &&fd.folderSize < 1099511627776 }">
										<fmt:formatNumber  type="number" value="${fd.folderSize/1073741824 }" pattern="#0.0"></fmt:formatNumber>G
									</c:when>
									<c:otherwise>
										<fmt:formatNumber  type="number" value="${fd.folderSize/1073741824*1024 }" pattern="#0.0"></fmt:formatNumber>T
									</c:otherwise>
								</c:choose>
							
								
							</td>
							<td>${fd.user.userName }</td>
							
							
							<c:choose>
								<c:when test="${fd.fileNum == 0 }">
									<td><a  href="file.jspx?m=delFolder&id=${fd.folderId}" ><i class="icon-trash" class="pull-right" ></i></a></td>
								</c:when>
								<c:otherwise>
									<td><a  href="#myModal2" data-toggle="modal" ><i class="icon-trash" class="pull-right" ></i></a></td>
								</c:otherwise>
							</c:choose>
						</tr>
						
						
					<div id="myModal2" class="modal hide fade" style="display: none;">
					    <div class="modal-header">
						    <a class="close" data-dismiss="modal">×</a>
						    	<h3>亲……您无法删除该文件夹！</h3>
						</div>
					    <div class="modal-body">
					   		 <p style="color:green;">只有当文件夹不包含文件时，才可以删除！</p>
					    </div>
					    <div class="modal-footer">
					   		
					    	<a class="btn btn-primary" data-dismiss="modal" href="#">确定</a>
					    </div>
				   </div>
						
						
						
						
						
						
						
						</c:forEach>
							</c:otherwise>
						</c:choose>
						
						
						
					</tbody>
				</table>
				
				
				
			<!--以下是分页功能，在页面显示靠右时使用 pagination-right而不是pull-right -->
			    <div class="pagination pagination-right">
				    <ul>
				    	<c:choose>
					  		<c:when test="${requestScope.folderpage.pageNum == 1 }">
					  			 <li><a href="#">首页</a></li>
					  		</c:when>
					  		<c:otherwise>
					  			<li><a href="file.jspx?p=1">首页</a></li>
					  		</c:otherwise>
					  	</c:choose>
					  	<c:choose>
					  		<c:when test="${requestScope.folderpage.pageNum == 1}">
					  			<li><a href="#">上一页</a></li>
					  		</c:when>
					  		<c:otherwise>
					  			<li><a href="file.jspx?p=${requestScope.folderpage.pageNum - 1 }">上一页</a></li>
					  		</c:otherwise>
					  	</c:choose>
					  	<c:choose>
					  		<c:when test="${requestScope.folderpage.pageNum == requetScope.folderpage.totalPages }">
					  			<li><a href="#">下一页</a></li>
					  		</c:when>
					  		<c:otherwise>
					  			<li><a href="file.jspx?p=${requestScope.folderpage.pageNum + 1 }">下一页</a></li>
					  		</c:otherwise>
					  	</c:choose>
					  	<c:choose>
					  		<c:when test="${requestScope.folderpage.pageNum == requestScope.folderpage.totalPages }">
					  			<li><a href="#">尾页</a></li>
					  		</c:when>
					  		<c:otherwise>
					  			<li><a href="file.jspx?p=${requestScope.folderpage.totalPages }">尾页</a></li>
					  		</c:otherwise>
					  	</c:choose>
					   
					  
				    </ul>
				    </div>							
			</div>
			
			
		</div>
	  </div>
	</div>
	
	
	
	
	
	<script type="text/javascript" src="styles/jquery/jquery.js"></script>
	<script type="text/javascript" src="styles/js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#showModal2").click(function(){
				$("#myModal2").modal();
				
			});
		});
	</script>
  </body>
</html>
